Change in openvpn[master]: multi: release the session-id hash reference on shutdown
A message that is not in the archive (sent off-list or not yet received): gerrit.1792965388000.I62d95dad21891351a16cd6be43063406a024acee@gerrit.openvpn.net
Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
to review the following change.
Change subject: multi: release the session-id hash reference on shutdown
......................................................................
multi: release the session-id hash reference on shutdown
multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table without releasing the reference, so every instance still connected when the server stops is leaked (reported by LeakSanitizer, which also turns the exit code into 1).
Remove the instance from the session-id hash regardless of shutdown. Unlike the other tables handled in that block, this one holds a reference.
---
M src/openvpn/multi.c
1 file changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/2032/1
src/openvpn/multi.c +7 -6
@@ -584,6 +584,13 @@ m->earliest_wakeup =NULL ; } +/* The sid hash holds a reference on the instance: drop it on shutdown +* too, otherwise the instance is never freed */ +if (session_id_defined (&mi->sid_hashed_value)) + { +multi_hash_sid_remove (m, &mi->sid_hashed_value); + } +if (!shutdown) {if (mi->did_real_hash)
@@ -605,12 +612,6 @@ }#endif - -if (session_id_defined (&mi->sid_hashed_value)) - { -multi_hash_sid_remove (m, &mi->sid_hashed_value); - } -if (mi->context.c2.tls_multi->rx_peer_id !=MAX_PEER_ID ) { m->instances[mi->context.c2.tls_multi->rx_peer_id] =NULL ;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: Antonio Quartulli.
Arne Schwabe has posted comments on this change by Antonio Quartulli. ( https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email )
Change subject: multi: release the session-id hash reference on shutdown
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Antonio Quartulli <[email protected]>
Gerrit-Comment-Date: Sun, 25 Oct 2026 22:24:25 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
PATCH 1/1 multi: release the session-id hash reference on shutdown
In reply to a message not in the archiveFrom: Antonio Quartulli <[email protected]>
multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table without releasing the reference, so every instance still connected when the server stops is leaked (reported by LeakSanitizer, which also turns the exit code into 1).
Remove the instance from the session-id hash regardless of shutdown. Unlike the other tables handled in that block, this one holds a reference.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]>
src/openvpn/multi.c +7 -6
@@ -584,6 +584,13 @@ m->earliest_wakeup =NULL ; } +/* The sid hash holds a reference on the instance: drop it on shutdown +* too, otherwise the instance is never freed */ +if (session_id_defined (&mi->sid_hashed_value)) + { +multi_hash_sid_remove (m, &mi->sid_hashed_value); + } +if (!shutdown) {if (mi->did_real_hash)
@@ -605,12 +612,6 @@ }#endif - -if (session_id_defined (&mi->sid_hashed_value)) - { -multi_hash_sid_remove (m, &mi->sid_hashed_value); - } -if (mi->context.c2.tls_multi->rx_peer_id !=MAX_PEER_ID ) { m->instances[mi->context.c2.tls_multi->rx_peer_id] =NULL ;
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH applied] Re: multi: release the session-id hash reference on shutdown
This seems to make sense (and if Arne says so, I won't argue). BB all green, too.
I have amended the comment a bit, because "... for shutdown, too" does not really make sense if this ends up being the only place where it happens (it makes sense in the commit message).
Your patch has been applied to the master branch.
commit 3e2d92c7f7e53f329795c865cb36d1fc788e9a9a
Author: Antonio Quartulli Date: Mon Oct 26 12:03:24 2026 +0100
multi: release the session-id hash reference on shutdown
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg40135.html
--
kind regards,
Gert Doering
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: Antonio Quartulli.
Gert Doering has posted comments on this change by Antonio Quartulli. ( https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email )
Change subject: multi: release the session-id hash reference on shutdown
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/multi.c:
https://gerrit.openvpn.net/c/openvpn/+/2032/comment/ed22418e_7b59fb5c?usp=email :
PS1, Line 588: * too, otherwise the instance is never freed */
this sort of comment ("drop it on shutdown *too*") makes sense in a commit message, but not so much in the code - a reader 3 years from now will ask "too, compared to what?". So I'll reword this on commit to something like
``` /* The sid hash holds a reference on the instance, drop it so the instance * can be freed competely */ ```
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Antonio Quartulli <[email protected]>
Gerrit-Comment-Date: Sat, 31 Oct 2026 16:42:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Gert Doering has uploaded a new patch set (#2) to the change originally created by Antonio Quartulli. ( https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by Arne Schwabe
Change subject: multi: release the session-id hash reference on shutdown
......................................................................
multi: release the session-id hash reference on shutdown
multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table without releasing the reference, so every instance still connected when the server stops is leaked (reported by LeakSanitizer, which also turns the exit code into 1).
Remove the instance from the session-id hash regardless of shutdown. Unlike the other tables handled in that block, this one holds a reference.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg40135.html
---
M src/openvpn/multi.c
1 file changed, 7 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/2032/2
src/openvpn/multi.c +7 -6
@@ -584,6 +584,13 @@ m->earliest_wakeup =NULL ; } +/* The sid hash holds a reference on the instance: drop it on +* instance close, otherwise the instance is never freed */ +if (session_id_defined (&mi->sid_hashed_value)) + { +multi_hash_sid_remove (m, &mi->sid_hashed_value); + } +if (!shutdown) {if (mi->did_real_hash)
@@ -605,12 +612,6 @@ }#endif - -if (session_id_defined (&mi->sid_hashed_value)) - { -multi_hash_sid_remove (m, &mi->sid_hashed_value); - } -if (mi->context.c2.tls_multi->rx_peer_id !=MAX_PEER_ID ) { m->instances[mi->context.c2.tls_multi->rx_peer_id] =NULL ;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 2
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Gert Doering has submitted this change. ( https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email )
Change subject: multi: release the session-id hash reference on shutdown
......................................................................
multi: release the session-id hash reference on shutdown
multi_hash_sid_add() takes a reference on the multi_instance, but multi_close_instance() only drops it via multi_hash_sid_remove() when not shutting down. On shutdown hash_free() then frees the table without releasing the reference, so every instance still connected when the server stops is leaked (reported by LeakSanitizer, which also turns the exit code into 1).
Remove the instance from the session-id hash regardless of shutdown. Unlike the other tables handled in that block, this one holds a reference.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2032
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg40135.html
---
M src/openvpn/multi.c
1 file changed, 7 insertions(+), 6 deletions(-)
src/openvpn/multi.c +7 -6
@@ -584,6 +584,13 @@ m->earliest_wakeup =NULL ; } +/* The sid hash holds a reference on the instance: drop it on +* instance close, otherwise the instance is never freed */ +if (session_id_defined (&mi->sid_hashed_value)) + { +multi_hash_sid_remove (m, &mi->sid_hashed_value); + } +if (!shutdown) {if (mi->did_real_hash)
@@ -605,12 +612,6 @@ }#endif - -if (session_id_defined (&mi->sid_hashed_value)) - { -multi_hash_sid_remove (m, &mi->sid_hashed_value); - } -if (mi->context.c2.tls_multi->rx_peer_id !=MAX_PEER_ID ) { m->instances[mi->context.c2.tls_multi->rx_peer_id] =NULL ;
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2032?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I62d95dad21891351a16cd6be43063406a024acee
Gerrit-Change-Number: 2032
Gerrit-PatchSet: 2
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: Gert Doering <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel